home *** CD-ROM | disk | FTP | other *** search
- Subject: v19i048: FBM, image manipulation library, Part02/08
- Newsgroups: comp.sources.unix
- Sender: sources
- Approved: rsalz@uunet.UU.NET
-
- Submitted-by: Michael.Mauldin@NL.CS.CMU.EDU
- Posting-number: Volume 19, Issue 48
- Archive-name: fbm/part02
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 2 (of 8)."
- # Contents: clr2gray.c fbcat.1 fbcat.c fbclean.c fbedge.c fbext.1
- # fbhist.c fbinfo.c fbmask.c fbquant.1 fbrot.c fbsample.1 fbsharp.c
- # flcavg.c flthre.c flwrfb.c gray2clr.c qrt2fbm.c
- # Wrapped by rsalz@fig.bbn.com on Fri Jun 9 08:38:21 1989
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'clr2gray.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'clr2gray.c'\"
- else
- echo shar: Extracting \"'clr2gray.c'\" \(2601 characters\)
- sed "s/^X//" >'clr2gray.c' <<'END_OF_FILE'
- X/*****************************************************************
- X * clr2gray.c: FBM Library 0.9 (Beta test) 07-Mar-89 Michael Mauldin
- X *
- X * Copyright (C) 1989 by Michael Mauldin. Permission is granted to
- X * use this file in whole or in part provided that you do not sell it
- X * for profit and that this copyright notice is retained unchanged.
- X *
- X * USAGE
- X * % clr2gray [ -r<red> -g<grn> -b<blu> ] [ -<type> ] < color > gray
- X *
- X * EDITLOG
- X * LastEditDate = Tue Mar 7 19:56:03 1989 - Michael Mauldin
- X * LastFileName = /usr2/mlm/src/misc/fbm/clr2gray.c
- X *
- X * HISTORY
- X * 07-Mar-89 Michael Mauldin (mlm) at Carnegie Mellon University
- X * Beta release (version 0.9) mlm@cs.cmu.edu
- X *
- X * 06-Mar-89 Michael Mauldin (mlm) at Carnegie Mellon University
- X * Added options for RGB weights
- X *
- X * 1-Dec-88 Michael Mauldin (mlm) at Carnegie-Mellon University
- X * Created.
- X *****************************************************************/
- X
- X# include <stdio.h>
- X# include <math.h>
- X# include "fbm.h"
- X
- X# define USAGE \
- X"Usage: clr2gray [ -r<red> -g<grn> -b<blu> ] [ -<type> ] < color > gray"
- X
- X#ifndef lint
- Xstatic char *fbmid =
- X "$FBM clr2gray.c <0.9> 07-Mar-89 (C) 1989 by Michael Mauldin$";
- X#endif
- X
- Xmain (argc, argv)
- Xchar *argv[];
- X{ FBM input, output;
- X int outtype = DEF_8BIT;
- X int rw=0, gw=0, bw=0;
- X
- X /* Get the options */
- X while (--argc > 0 && (*++argv)[0] == '-')
- X { while (*++(*argv))
- X { switch (**argv)
- X {
- X case 'r': rw = atoi (*argv+1); SKIPARG; break;
- X case 'g': gw = atoi (*argv+1); SKIPARG; break;
- X case 'b': bw = atoi (*argv+1); SKIPARG; break;
- X case 'A': outtype = FMT_ATK; break;
- X case 'B': outtype = FMT_FACE; break;
- X case 'F': outtype = FMT_FBM; break;
- X case 'G': outtype = FMT_GIF; break;
- X case 'I': outtype = FMT_IFF; break;
- X case 'L': outtype = FMT_LEAF; break;
- X case 'M': outtype = FMT_MCP; break;
- X case 'P': outtype = FMT_PBM; break;
- X case 'S': outtype = FMT_SUN; break;
- X case 'T': outtype = FMT_TIFF; break;
- X case 'X': outtype = FMT_X11; break;
- X case 'Z': outtype = FMT_PCX; break;
- X default: fprintf (stderr, "%s\n", USAGE);
- X exit (1);
- X }
- X }
- X }
- X
- X /* Use NTSC weights for defaults */
- X if (rw + gw + bw <= 0)
- X { rw = 299; gw = 587; bw = 114; }
- X
- X /* Clear the memory pointers so alloc_fbm won't be confused */
- X input.cm = input.bm = (unsigned char *) NULL;
- X output.cm = output.bm = (unsigned char *) NULL;
- X
- X /* Read the image and convert it, use NTSC weights */
- X if (read_bitmap (&input, (char *) NULL) &&
- X clr2gray (&input, &output, rw, gw, bw) &&
- X write_bitmap (&output, stdout, outtype))
- X { exit (0); }
- X
- X exit (1);
- X}
- END_OF_FILE
- if test 2601 -ne `wc -c <'clr2gray.c'`; then
- echo shar: \"'clr2gray.c'\" unpacked with wrong size!
- fi
- # end of 'clr2gray.c'
- fi
- if test -f 'fbcat.1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'fbcat.1'\"
- else
- echo shar: Extracting \"'fbcat.1'\" \(2241 characters\)
- sed "s/^X//" >'fbcat.1' <<'END_OF_FILE'
- X.TH FBCAT 1 07-Mar-89
- X.CM 3
- X.SH NAME
- Xfbcat \- convert image format
- X.SH SYNOPSIS
- X.nf
- Xfbcat [ -a<aspect> -t'title' -c'credits' ] [ -<type> ] [ image ] > image
- X.fi
- X.SH DESCRIPTION
- X.PP
- XA general format converter. It can read any of the known formats
- Xand write one of the specified output formats (see fbm(1) for format
- Xdetails). Note that some conversions require more than simple format
- Xchanges, such as color to grayscale or grayscale to 1bit. For these
- Xconversion you must use a pipeline of ther commands.
- X.SH OPTIONS
- X.TP
- X.BR -a<aspect>
- X.I aspect ratio,
- Xa floating point number which is the ratio of the height of a pixel to
- Xits width. Some formats specify this, and for GIF images the reader
- Xattempts to guess from the size of the image. This option overrides
- Xthe input or guessed aspect ratio. So if you know that your GIF image
- Xhas a 1-1 aspect ratio, you should specify -a1 to override the guess.
- X.TP
- X.BR -t'title'
- X.I title,
- Xspecify a character string (up to 80 characters) to describe the image.
- XThe default is no title.
- X.TP
- X.BR -c'credits'
- X.I credits or subtitle,
- Xspecify a second character string (up to 80 characters) to describe the
- Ximage. The default is no credit string.
- X.TP
- X.BR -B
- X.I face
- Xformat, as used by Bennet Yee's
- X.I face
- Xprogram at CMU.
- X.TP
- X.BR -F
- X.I FBM,
- Xformat (by default, the default). You are guaranteed not
- Xto lose information by specifying FBM as the default.
- X.TP
- X.BR -G
- X.I GIF,
- XCompuserve GIF format.
- X.TP
- X.BR -I
- X.I IFF
- Xformat, interleaved bitmaps (ILBM), used by Amigas.
- X.TP
- X.BR -P
- X.I PBM,
- XJef Poskanzer's bitmap format.
- X.TP
- X.BR -S
- X.I sun,
- XSun rasterfiles (not run length encoded).
- X.SH EXAMPLE
- X.PP
- XTo convert a GIF file to an IFF file
- X.sp
- X % fbcat -I < foo.gif > foo.iff
- X.sp
- XTo convert a Sun raster file to an FBM file, adding a title:
- X.sp
- X % fbcat -t'Title String' < bar.8bit > bar.fbm
- X.SH SEE ALSO
- Xfbm(1) for general discussion, pbm(1) for PBM routines.
- X.SH BUGS
- XNone known.
- X.SH HISTORY
- XCopyright (c) 1989 by Michael L. Mauldin.
- XPermission is granted to use this program in whole or in part provided
- Xthat you do not sell it for profit and that this copyright notice is
- Xretained unchanged.
- X.TP
- X07-Mar-89 Michael L. Mauldin at Carnegie Mellon University
- XBeta release (version 0.9) mlm@cs.cmu.edu
- END_OF_FILE
- if test 2241 -ne `wc -c <'fbcat.1'`; then
- echo shar: \"'fbcat.1'\" unpacked with wrong size!
- fi
- # end of 'fbcat.1'
- fi
- if test -f 'fbcat.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'fbcat.c'\"
- else
- echo shar: Extracting \"'fbcat.c'\" \(3257 characters\)
- sed "s/^X//" >'fbcat.c' <<'END_OF_FILE'
- X/*****************************************************************
- X * fbcat.c: FBM Library 0.9 (Beta test) 07-Mar-89 Michael Mauldin
- X *
- X * Copyright (C) 1989 by Michael Mauldin. Permission is granted to
- X * use this file in whole or in part provided that you do not sell it
- X * for profit and that this copyright notice is retained unchanged.
- X *
- X * fbcat.c:
- X * Convert an image from one format to another. Input image type
- X * is determined by magic number. Output is specified by argument.
- X * Note that the ascpect ratio, size and number of colors is not
- X * changed, and that some conversions (such as grayscale to bitmap
- X * or color to gray require more processing than fbcat can do.
- X * For these transformations you must use other programs like
- X * clr2gray, gray2clr, fbhalf, and fbsample.
- X *
- X * USAGE
- X * % fbcat [ -t'title' -c'credits' ] [ -<type> ] [ image ] > image
- X *
- X * EDITLOG
- X * LastEditDate = Wed May 3 22:03:33 1989 - Michael Mauldin
- X * LastFileName = /usr2/mlm/src/misc/fbm/fbcat.c
- X *
- X * HISTORY
- X * 07-Mar-89 Michael Mauldin (mlm) at Carnegie Mellon University
- X * Beta release (version 0.9) mlm@cs.cmu.edu
- X *
- X * 29-Nov-88 Michael Mauldin (mlm) at Carnegie-Mellon University
- X * Created.
- X *****************************************************************/
- X
- X
- X# include <stdio.h>
- X# include "fbm.h"
- X
- X# define USAGE \
- X"Usage: fbcat [ -a<aspect> -t'title' -c'credits' ]\n\
- X [ -<type> ] [ image ] > image"
- X
- X/****************************************************************
- X * main
- X ****************************************************************/
- X
- X#ifndef lint
- Xstatic char *fbmid =
- X "$FBM fbcat.c <0.9> 07-Mar-89 (C) 1989 by Michael Mauldin$";
- X#endif
- X
- Xmain (argc, argv)
- Xchar *argv[];
- X{ FBM image;
- X int outtype = FMT_FBM;
- X double aspect = 0.0;
- X char *title = NULL, *credits = NULL;
- X
- X /* Get the options */
- X while (--argc > 0 && (*++argv)[0] == '-')
- X { while (*++(*argv))
- X { switch (**argv)
- X {
- X case 'a': aspect = atof (*argv+1); SKIPARG; break;
- X case 't': title = *argv+1; SKIPARG; break;
- X case 'c': credits = *argv+1; SKIPARG; break;
- X case 'A': outtype = FMT_ATK; break;
- X case 'B': outtype = FMT_FACE; break;
- X case 'F': outtype = FMT_FBM; break;
- X case 'G': outtype = FMT_GIF; break;
- X case 'I': outtype = FMT_IFF; break;
- X case 'M': outtype = FMT_MCP; break;
- X case 'P': outtype = FMT_PBM; break;
- X case 'S': outtype = FMT_SUN; break;
- X case 'T': outtype = FMT_TIFF; break;
- X case 'X': outtype = FMT_X11; break;
- X case 'Z': outtype = FMT_PCX; break;
- X default: fprintf (stderr, "%s\n", USAGE);
- X exit (1);
- X }
- X }
- X }
- X
- X /* Clear the memory pointers so alloc_fbm won't be confused */
- X image.cm = image.bm = (unsigned char *) NULL;
- X
- X /* Now read in the Sun format image and write an FBM format file */
- X if (read_bitmap (&image, (argc > 0) ? *argv : (char *) NULL))
- X {
- X if (aspect != 0.0)
- X { fprintf (stderr,
- X "Overiding aspect ratio read (%1.3lf) with (%1.3lf)\n",
- X image.hdr.aspect, aspect);
- X image.hdr.aspect = aspect;
- X }
- X
- X if (title)
- X { strncpy (image.hdr.title, title, FBM_MAX_TITLE); }
- X
- X if (credits)
- X { strncpy (image.hdr.credits, credits, FBM_MAX_TITLE); }
- X
- X if (write_bitmap (&image, stdout, outtype))
- X { exit (0);
- X }
- X }
- X
- X exit (1);
- X}
- END_OF_FILE
- if test 3257 -ne `wc -c <'fbcat.c'`; then
- echo shar: \"'fbcat.c'\" unpacked with wrong size!
- fi
- # end of 'fbcat.c'
- fi
- if test -f 'fbclean.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'fbclean.c'\"
- else
- echo shar: Extracting \"'fbclean.c'\" \(3425 characters\)
- sed "s/^X//" >'fbclean.c' <<'END_OF_FILE'
- X/*****************************************************************
- X * fbclean.c: FBM Library 0.9 (Beta test) 07-Mar-89 Michael Mauldin
- X *
- X * Copyright (C) 1989 by Michael Mauldin & Gary Sherwin.
- X * Permission is granted to use this file in whole or in part provided
- X * that you do not sell it for profit and that this copyright notice
- X * is retained unchanged.
- X *
- X * fbclean.c: Normalize contrast and brightness of image
- X *
- X * USAGE
- X * % fbclean [ flag ] < image > image2
- X *
- X * EDITLOG
- X * New Filename = fbclean.c Mon Nov 7 09:24:00 1988 - Gary Sherwin
- X * LastEditDate = Mon Oct 31 08:34:55 1988 - Michael Mauldin
- X * LastFileName = /usr2/mlm/src/misc/images/bsharp.c
- X * LastEditDate = Tue Mar 7 17:46:17 1989 - Michael Mauldin
- X * LastFileName = /usr2/mlm/src/misc/fbm/fbclean.c
- X *
- X * HISTORY
- X * 07-Mar-89 Michael Mauldin (mlm) at Carnegie Mellon University
- X * Beta release (version 0.9) mlm@cs.cmu.edu
- X *
- X * 07-Nov-88 Gary W. Sherwin (sherwin) at Westinghouse R&D
- X * Changed to fbclean.
- X *
- X * 10-Sep-88 Michael Mauldin (mlm) at Carnegie-Mellon University
- X * Created.
- X *****************************************************************/
- X
- X# include <stdio.h>
- X# include <math.h>
- X# include "fbm.h"
- X
- X# define USAGE \
- X "Usage: fbclean [ -b<cleaner> -t<threshhold> -n<nbr> ]\n\
- X [ -<type> ] < bitmap > bitmap"
- X
- X#ifndef lint
- Xstatic char *fbmid =
- X "$FBM fbclean.c <0.9> 07-Mar-89 (C) 1989 by Michael Mauldin$";
- X#endif
- X
- Xmain (argc, argv)
- Xchar *argv[];
- X{ int w, h, k;
- X int cleaner = 5;
- X int blacktrp = 0;
- X int nbr = 5;
- X int outtype = DEF_1BIT;
- X FBM input, output;
- X
- X /* Get the options */
- X while (--argc > 0 && (*++argv)[0] == '-')
- X { while (*++(*argv))
- X { switch (**argv)
- X { case 'b': cleaner = atoi (*argv+1); SKIPARG; break;
- X case 't': blacktrp = atoi (*argv+1); SKIPARG; break;
- X case 'n': nbr = atoi (*argv+1); SKIPARG; break;
- X case 'A': outtype = FMT_ATK; break;
- X case 'B': outtype = FMT_FACE; break;
- X case 'F': outtype = FMT_FBM; break;
- X case 'G': outtype = FMT_GIF; break;
- X case 'I': outtype = FMT_IFF; break;
- X case 'L': outtype = FMT_LEAF; break;
- X case 'M': outtype = FMT_MCP; break;
- X case 'P': outtype = FMT_PBM; break;
- X case 'S': outtype = FMT_SUN; break;
- X case 'T': outtype = FMT_TIFF; break;
- X case 'X': outtype = FMT_X11; break;
- X case 'Z': outtype = FMT_PCX; break;
- X default: fprintf (stderr, "%s\n", USAGE);
- X exit (1);
- X }
- X }
- X }
- X
- X /* Clear the memory pointers so alloc_fbm won't be confused */
- X input.cm = input.bm = (unsigned char *) NULL;
- X output.cm = output.bm = (unsigned char *) NULL;
- X
- X /* Read the image and clean it */
- X if (read_bitmap (&input, (char *) NULL))
- X {
- X if (input.hdr.bits != 8 || input.hdr.physbits != 8)
- X { fprintf (stderr,
- X "Can't handle images with %d bits and %d physbits per pixel\n",
- X input.hdr.bits, input.hdr.physbits);
- X exit (1);
- X }
- X
- X /* Determine output height & width (oh*ow <= size) */
- X h = input.hdr.rows;
- X w = input.hdr.cols;
- X k = input.hdr.planes;
- X
- X fprintf (stderr,
- X "Cleaning \"%s\", # of Neighbors %2d, nbr %d [%dx%dx%d]\n",
- X input.hdr.title[0] ? input.hdr.title : "(untitled)",
- X cleaner, nbr, w, h, k);
- X
- X /* Clean the image using a digitial Laplacian */
- X if (clean_fbm (&input, &output, cleaner, blacktrp, nbr) &&
- X write_bitmap (&output, stdout, outtype))
- X { exit (0); }
- X }
- X
- X exit (1);
- X}
- END_OF_FILE
- if test 3425 -ne `wc -c <'fbclean.c'`; then
- echo shar: \"'fbclean.c'\" unpacked with wrong size!
- fi
- # end of 'fbclean.c'
- fi
- if test -f 'fbedge.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'fbedge.c'\"
- else
- echo shar: Extracting \"'fbedge.c'\" \(3190 characters\)
- sed "s/^X//" >'fbedge.c' <<'END_OF_FILE'
- X/*****************************************************************
- X * fbedge.c: FBM Library 0.9 (Beta test) 07-Mar-89 Michael Mauldin
- X *
- X * Copyright (C) 1989 by Michael Mauldin & Gary Sherwin.
- X * Permission is granted to use this file in whole or in part provided
- X * that you do not sell it for profit and that this copyright notice
- X * is retained unchanged.
- X *
- X * fbedge.c: Take derivative and edge detect image
- X *
- X * USAGE
- X * % fbedge [ flag ] < image > image2
- X *
- X * EDITLOG
- X * New Filename = fbedge.c Mon Nov 7 09:24:00 1988 - Gary Sherwin
- X * LastEditDate = Mon Oct 31 08:34:55 1988 - Michael Mauldin
- X * LastFileName = /usr2/mlm/src/misc/images/bsharp.c
- X * LastEditDate = Tue Mar 7 17:50:04 1989 - Michael Mauldin
- X * LastFileName = /usr2/mlm/src/misc/fbm/fbedge.c
- X *
- X * HISTORY
- X * 07-Mar-89 Michael Mauldin (mlm) at Carnegie Mellon University
- X * Beta release (version 0.9) mlm@cs.cmu.edu
- X *
- X * 07-Nov-88 Gary W. Sherwin (sherwin) at Westinghouse R&D
- X * Changed to fbedge.
- X *
- X * 10-Sep-88 Michael Mauldin (mlm) at Carnegie-Mellon University
- X * Created.
- X *****************************************************************/
- X
- X# include <stdio.h>
- X# include <math.h>
- X# include "fbm.h"
- X
- X# define USAGE "Usage: fbedge [ -t<threshhold> ] < bitmap > bitmap"
- X
- X#ifndef lint
- Xstatic char *fbmid =
- X "$FBM fbedge.c <0.9> 07-Mar-89 (C) 1989 by Michael Mauldin$";
- X#endif
- X
- Xmain (argc, argv)
- Xchar *argv[];
- X{ int w, h, k;
- X int blacktrp = 0;
- X int outtype = DEF_1BIT;
- X FBM input, output;
- X
- X /* Get the options */
- X while (--argc > 0 && (*++argv)[0] == '-')
- X { while (*++(*argv))
- X { switch (**argv)
- X { case 't': blacktrp = atoi (*argv+1); SKIPARG; break;
- X case 'A': outtype = FMT_ATK; break;
- X case 'B': outtype = FMT_FACE; break;
- X case 'F': outtype = FMT_FBM; break;
- X case 'G': outtype = FMT_GIF; break;
- X case 'I': outtype = FMT_IFF; break;
- X case 'L': outtype = FMT_LEAF; break;
- X case 'M': outtype = FMT_MCP; break;
- X case 'P': outtype = FMT_PBM; break;
- X case 'S': outtype = FMT_SUN; break;
- X case 'T': outtype = FMT_TIFF; break;
- X case 'X': outtype = FMT_X11; break;
- X case 'Z': outtype = FMT_PCX; break;
- X default: fprintf (stderr, "%s\n", USAGE);
- X exit (1);
- X }
- X }
- X }
- X
- X /* Clear the memory pointers so alloc_fbm won't be confused */
- X input.cm = input.bm = (unsigned char *) NULL;
- X output.cm = output.bm = (unsigned char *) NULL;
- X
- X /* Read the image and clean it */
- X if (read_bitmap (&input, (char *) NULL))
- X {
- X if (input.hdr.bits != 8 || input.hdr.physbits != 8)
- X { fprintf (stderr,
- X "Can't handle images with %d bits and %d physbits per pixel\n",
- X input.hdr.bits, input.hdr.physbits);
- X exit (1);
- X }
- X
- X /* Determine output height & width (oh*ow <= size) */
- X h = input.hdr.rows;
- X w = input.hdr.cols;
- X k = input.hdr.planes;
- X
- X fprintf (stderr,
- X "Edge detect\"%s\", Black-trip %2d [%dx%dx%d]\n",
- X input.hdr.title[0] ? input.hdr.title : "(untitled)",
- X blacktrp, w, h, k);
- X
- X /* Edge detect the image using a digitial Laplacian */
- X if (findedge_fbm (&input, &output, blacktrp) &&
- X write_bitmap (&output, stdout, outtype))
- X { exit (0); }
- X }
- X
- X exit (1);
- X}
- END_OF_FILE
- if test 3190 -ne `wc -c <'fbedge.c'`; then
- echo shar: \"'fbedge.c'\" unpacked with wrong size!
- fi
- # end of 'fbedge.c'
- fi
- if test -f 'fbext.1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'fbext.1'\"
- else
- echo shar: Extracting \"'fbext.1'\" \(2772 characters\)
- sed "s/^X//" >'fbext.1' <<'END_OF_FILE'
- X.TH FBEXT 1 07-Mar-89
- X.CM 3
- X.SH NAME
- Xfbext \- extract a rectangle from an image, resize, change aspect ratio
- X.SH SYNOPSIS
- X.nf
- Xfbext [ -w<width> -h<height> -W<maxwdith> -H<maxheight>
- X -s<size> -a<aspect> -t'title' -c'credits' ] [ -<type> ]
- X [ x y [ width height ] ] < bitmap > bitmap
- X.fi
- X.SH DESCRIPTION
- X.PP
- XExtract a rectangle from a bitmap and resize it. There are lots of
- Xarguments, but you'll typically only give it a few. For example, you
- Xshould only specify two of width, height and aspect ratio, and it will
- Xcalculate the third. The rectangle spec is given as 2 or 4 positional
- Xarguments after the flags, and if omitted the entire input image is
- Xcopied.
- X.sp
- XThe maximum width and height override all other size specifications, so
- Xthey can be used ot keep the results displayable on your screen.
- X.sp
- XWhen working with Amiga images, remember that the original input has an
- Xaspect ratio of 1.2, so a common operation is "fbext -a1" which expands
- Xthe smaller dimension to give an output with an aspect ratio of 1.
- X.SH OPTIONS
- X.TP
- X.B -SPFB
- X.I output file format,
- XS=sun, P=pbm, F=fbm, B=face format. Only one may be specified.
- X.TP
- X.B -a
- X.I aspect ratio,
- Xspecify desired output aspect ratio.
- X.TP
- X.B -w
- X.I width,
- Xspecify desired output width in pixels.
- X.TP
- X.B -h
- X.I height,
- Xspecify desired output height in pixels.
- X.TP
- X.B -s
- X.I size,
- Xspecify desired number of pixels in output (eg: 320x200 is 64000 pixels.
- X.TP
- X.B -W
- X.I maximum width,
- Xof output. The image will be expanded up to this size, keeping the
- Xspecified aspect ratio.
- X.TP
- X.B -H
- X.I maximum height.,
- X.TP
- X.BR -t'title'
- X.I title,
- Xspecify a character string (up to 80 characters) to describe the image.
- XThe default is no title.
- X.TP
- X.BR -c'credits'
- X.I credits or subtitle,
- Xspecify a second character string (up to 80 characters) to describe the
- Ximage. The default is no credit string.
- X.PP
- X.SH EXAMPLE
- X.PP
- XSuppose you have a GIF file with 320 by 200 pixels and an aspect ratio
- Xof 1.2 (that is, it looks right at 320 by 240 pixels). You want to
- Xblow it up to fit your Sun screen (1152 by 900). You want the output
- Xratio adjusted to be 1.0 so it will look right on the Sun.
- X.sp
- Xfbext -S -W1152 -H900 -a1.0 < foo.gif > foo.raster
- X.sp
- XYou have an FBM format file 512 by 384 and you want to extract a
- Xrectangle 300 by 200 from the middle:
- X.sp
- Xfbext -F 106 92 300 200 < foo.fbm > bar.fbm
- X.sp
- X.SH SEE ALSO
- Xfbm(1) for general discussion, pbm(1) for PBM routines.
- X.SH BUGS
- XNone known.
- X.SH HISTORY
- XCopyright (c) 1989 by Michael L. Mauldin.
- XPermission is granted to use this program in whole or in part provided
- Xthat you do not sell it for profit and that this copyright notice is
- Xretained unchanged.
- X.TP
- X07-Mar-89 Michael L. Mauldin at Carnegie Mellon University
- XBeta release (version 0.9) mlm@cs.cmu.edu
- END_OF_FILE
- if test 2772 -ne `wc -c <'fbext.1'`; then
- echo shar: \"'fbext.1'\" unpacked with wrong size!
- fi
- # end of 'fbext.1'
- fi
- if test -f 'fbhist.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'fbhist.c'\"
- else
- echo shar: Extracting \"'fbhist.c'\" \(2725 characters\)
- sed "s/^X//" >'fbhist.c' <<'END_OF_FILE'
- X/*****************************************************************
- X * fbhist.c: FBM Library 0.9 (Beta test) 07-Mar-89 Michael Mauldin
- X *
- X * Copyright (C) 1989 by Michael Mauldin. Permission is granted to
- X * use this file in whole or in part provided that you do not sell it
- X * for profit and that this copyright notice is retained unchanged.
- X *
- X * fbhist.c:
- X *
- X * USAGE
- X * % fbhist [-h] < image
- X *
- X * EDITLOG
- X * LastEditDate = Tue Mar 7 17:52:50 1989 - Michael Mauldin
- X * LastFileName = /usr2/mlm/src/misc/fbm/fbhist.c
- X *
- X * HISTORY
- X * 07-Mar-89 Michael Mauldin (mlm) at Carnegie Mellon University
- X * Beta release (version 0.9) mlm@cs.cmu.edu
- X *
- X * 21-Aug-88 Michael Mauldin (mlm) at Carnegie-Mellon University
- X * Created.
- X *****************************************************************/
- X
- X# include <stdio.h>
- X# include <math.h>
- X# include "fbm.h"
- X
- X#define USAGE "Usage: fbhist [ -h ] < 8bit"
- X
- X#ifndef lint
- Xstatic char *fbmid =
- X "$FBM fbhist.c <0.9> 07-Mar-89 (C) 1989 by Michael Mauldin$";
- X#endif
- X
- Xmain (argc, argv)
- Xchar *argv[];
- X{ FBM image;
- X register int ch, size, cnt;
- X register unsigned char *bmptr, *tail;
- X int min = BYTE, max = -1;
- X int hist[BYTE], dohist = 0;
- X double sum = 0.0, sumsq = 0.0, avg, std;
- X
- X /* Get the options */
- X while (--argc > 0 && (*++argv)[0] == '-')
- X { while (*++(*argv))
- X { switch (**argv)
- X { case 'h': dohist++; break;
- X default: fprintf (stderr, "%s\n", USAGE);
- X exit (1);
- X }
- X }
- X }
- X
- X /* Clear the memory pointer so alloc_fbm won't be confused */
- X image.cm = image.bm = (unsigned char *) NULL;
- X
- X /* Clear the histogram */
- X for (ch=0; ch<BYTE; ch++)
- X { hist[ch] = 0; }
- X
- X /* Read the file and count the gray levels */
- X if (read_bitmap (&image, (char *) NULL))
- X { size = image.hdr.rows * image.hdr.cols;
- X bmptr = image.bm;
- X tail = bmptr+size;
- X
- X while (bmptr < tail)
- X { hist[*bmptr++]++; }
- X
- X for (ch=0; ch<BYTE; ch++)
- X { cnt = hist[ch];
- X
- X if (cnt && ch < min) min = ch;
- X if (cnt && ch > max) max = ch;
- X
- X sum += cnt * ch;
- X sumsq += cnt * ch*ch;
- X }
- X
- X avg = sum / size;
- X
- X if (size < 2)
- X { std = 0.0; }
- X else
- X { double t1 = (size * sumsq - sum * sum);
- X double t2 = ((double) size * (size-1));
- X std = sqrt (t1 / t2);
- X }
- X
- X printf ("%s [%dx%d %d bits %1.3lf aspect ratio]\n",
- X *image.hdr.title ? image.hdr.title : "Untitled",
- X image.hdr.cols, image.hdr.rows, image.hdr.bits, image.hdr.aspect);
- X
- X printf ("Mean %1.2lf +- %1.2lf, range %d..%d\n",
- X avg, std, min, max);
- X
- X if (dohist)
- X { for (ch=0; ch<BYTE; ch++)
- X { if (hist[ch]) printf ("%3d: %6d\n", ch, hist[ch]); }
- X }
- X
- X }
- X else
- X { exit (1); }
- X
- X exit (0);
- X}
- END_OF_FILE
- if test 2725 -ne `wc -c <'fbhist.c'`; then
- echo shar: \"'fbhist.c'\" unpacked with wrong size!
- fi
- # end of 'fbhist.c'
- fi
- if test -f 'fbinfo.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'fbinfo.c'\"
- else
- echo shar: Extracting \"'fbinfo.c'\" \(2683 characters\)
- sed "s/^X//" >'fbinfo.c' <<'END_OF_FILE'
- X/*****************************************************************
- X * fbinfo.c: FBM Library 0.93 (Beta test) 03-May-89 Michael Mauldin
- X *
- X * Copyright (C) 1989 by Michael Mauldin. Permission is granted to
- X * use this file in whole or in part provided that you do not sell it
- X * for profit and that this copyright notice is retained unchanged.
- X *
- X * fbinfo.c:
- X *
- X * USAGE
- X * % fbinfo files...
- X *
- X * EDITLOG
- X * LastEditDate = Wed May 3 23:07:18 1989 - Michael Mauldin
- X * LastFileName = /usr2/mlm/src/misc/fbm/fbinfo.c
- X *
- X * HISTORY
- X * 03-May-89 Michael Mauldin (mlm) at Carnegie Mellon University
- X * Beta release (version 0.93) mlm@cs.cmu.edu
- X *
- X * 26-Sep-88 Michael Mauldin (mlm) at Carnegie-Mellon University
- X * Created.
- X *****************************************************************/
- X
- X
- X# include <stdio.h>
- X# include <math.h>
- X# include "fbm.h"
- X
- X# define USAGE "Usage: fbinfo files..."
- X
- X#ifndef lint
- Xstatic char *fbmid =
- X "$FBM fbinfo.c <0.93> 03-May-89 (C) 1989 by Michael Mauldin$";
- X#endif
- X
- Xmain (argc, argv)
- Xchar *argv[];
- X{ register int i;
- X FILE *infile;
- X char name[128], cmd[256];
- X
- X if (argc == 1)
- X { binfo ((char *) NULL, stdin); }
- X else
- X { for (i=1; i<argc; i++)
- X { strcpy (name, argv[i]);
- X
- X if (strcmp (name + strlen (name) - 2, ".Z") == 0)
- X { sprintf (cmd, "(uncompress < %s | select 0 255) 2> /dev/null", name);
- X if (infile = popen (cmd, "r"))
- X { binfo (name, infile); pclose (infile); }
- X else
- X { perror (cmd); }
- X }
- X else if (infile = fopen (argv[i], "r"))
- X { binfo (argv[i], infile); fclose (infile); }
- X else
- X { perror (argv[i]); }
- X }
- X }
- X}
- X
- Xbinfo (name, file)
- Xchar *name;
- XFILE *file;
- X{ FBM image;
- X FBMHDR *hdr;
- X
- X image.cm = image.bm = (unsigned char *) NULL;
- X
- X /* Read the file header format the bitmap description */
- X if (read_hdr_fbm (&image, file, (char *) NULL, 0))
- X { hdr = &(image.hdr);
- X
- X if (name) printf ("%-15s\t", name);
- X
- X if (hdr->title[0]) { printf ("\"%s\"\n", hdr->title); }
- X else { printf ("(untitled)\n"); }
- X
- X if (hdr->credits[0])
- X { if (name) printf ("\t\t");
- X printf ("[ %s ]\n", hdr->credits);
- X }
- X
- X if (name) printf ("\t\t");
- X
- X if (hdr->planes == 1)
- X { printf ("[%dx%dx%d] %d physbits %1.4lg aspect ratio\n",
- X hdr->cols, hdr->rows, hdr->bits, hdr->physbits, hdr->aspect);
- X }
- X else
- X { printf ("[%dx%dx%dx%d] %d physbits %1.4lg aspect ratio\n",
- X hdr->planes, hdr->cols, hdr->rows, hdr->bits, hdr->physbits,
- X hdr->aspect);
- X }
- X
- X if (name) printf ("\t\t");
- X
- X printf ("row length %d, plane length %d, colormap length %d\n",
- X hdr->rowlen, hdr->plnlen, hdr->clrlen);
- X
- X return (1);
- X }
- X
- X return (0);
- X}
- END_OF_FILE
- if test 2683 -ne `wc -c <'fbinfo.c'`; then
- echo shar: \"'fbinfo.c'\" unpacked with wrong size!
- fi
- # end of 'fbinfo.c'
- fi
- if test -f 'fbmask.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'fbmask.c'\"
- else
- echo shar: Extracting \"'fbmask.c'\" \(2815 characters\)
- sed "s/^X//" >'fbmask.c' <<'END_OF_FILE'
- X/*****************************************************************
- X * fbmask.c: FBM Library 0.9 (Beta test) 07-Mar-89 Michael Mauldin
- X *
- X * Copyright (C) 1989 by Michael Mauldin. Permission is granted to
- X * use this file in whole or in part provided that you do not sell it
- X * for profit and that this copyright notice is retained unchanged.
- X *
- X * fbmask.c: Mask a rectangle with a value (or average)
- X *
- X * USAGE
- X * % fbmask [ flags ] arguments
- X *
- X * EDITLOG
- X * LastEditDate = Tue Mar 7 19:56:33 1989 - Michael Mauldin
- X * LastFileName = /usr2/mlm/src/misc/fbm/fbmask.c
- X *
- X * HISTORY
- X * 07-Mar-89 Michael Mauldin (mlm) at Carnegie Mellon University
- X * Beta release (version 0.9) mlm@cs.cmu.edu
- X *
- X * 29-Aug-88 Michael Mauldin (mlm) at Carnegie-Mellon University
- X * Created.
- X *****************************************************************/
- X
- X# include <stdio.h>
- X# include <math.h>
- X# include "fbm.h"
- X
- X# define USAGE "Usage: fbmask [ -<type> ] x0 y0 x1 y1 value < 8bit > 8bit"
- X
- X#ifndef lint
- Xstatic char *fbmid =
- X "$FBM fbmask.c <0.9> 07-Mar-89 (C) 1989 by Michael Mauldin$";
- X#endif
- X
- Xmain (argc, argv)
- Xchar *argv[];
- X{ FBM image;
- X register int j, i, val, rowlen;
- X int x1, x0, y1, y0, n;
- X int outtype = DEF_8BIT;
- X
- X /* Clear the memory pointer so alloc_fbm won't be confused */
- X image.cm = image.bm = (unsigned char *) NULL;
- X
- X /* Get the options */
- X while (--argc > 0 && (*++argv)[0] == '-')
- X { while (*++(*argv))
- X { switch (**argv)
- X {
- X case 'A': outtype = FMT_ATK; break;
- X case 'B': outtype = FMT_FACE; break;
- X case 'F': outtype = FMT_FBM; break;
- X case 'G': outtype = FMT_GIF; break;
- X case 'I': outtype = FMT_IFF; break;
- X case 'L': outtype = FMT_LEAF; break;
- X case 'M': outtype = FMT_MCP; break;
- X case 'P': outtype = FMT_PBM; break;
- X case 'S': outtype = FMT_SUN; break;
- X case 'T': outtype = FMT_TIFF; break;
- X case 'X': outtype = FMT_X11; break;
- X case 'Z': outtype = FMT_PCX; break;
- X default: fprintf (stderr, "%s\n", USAGE);
- X exit (1);
- X }
- X }
- X }
- X
- X /* Get arguments */
- X if (argc != 5)
- X { fprintf (stderr, "%s\n", USAGE);
- X exit (1);
- X }
- X
- X x0 = atoi (argv[0]);
- X y0 = atoi (argv[1]);
- X x1 = atoi (argv[2]);
- X y1 = atoi (argv[3]);
- X val = atoi (argv[4]);
- X
- X /* Assure x0<x1 and y0<y1, swap if necessary */
- X if (x0 > x1) { n=x0; x0=x1; x1=n; }
- X if (y0 > y1) { n=y0; y0=y1; y1=n; }
- X
- X if (read_bitmap (&image, (char *) NULL))
- X {
- X if (image.hdr.planes > 1 ||
- X image.hdr.clrlen > 0 ||
- X image.hdr.physbits != 8)
- X { fprintf (stderr, "fbmask works only for 8bit grayscale files\n");
- X exit (1);
- X }
- X
- X rowlen = image.hdr.rowlen;
- X
- X for (j=y0; j<=y1; j++)
- X { for (i=x0; i<=x1; i++)
- X { image.bm[j*rowlen + i] = val; }
- X }
- X
- X write_bitmap (&image, stdout, outtype);
- X }
- X else
- X { exit (1); }
- X
- X exit (0);
- X}
- END_OF_FILE
- if test 2815 -ne `wc -c <'fbmask.c'`; then
- echo shar: \"'fbmask.c'\" unpacked with wrong size!
- fi
- # end of 'fbmask.c'
- fi
- if test -f 'fbquant.1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'fbquant.1'\"
- else
- echo shar: Extracting \"'fbquant.1'\" \(2737 characters\)
- sed "s/^X//" >'fbquant.1' <<'END_OF_FILE'
- X.TH FBQUANT 1 07-Apr-89
- X.CM 3
- X.SH NAME
- Xfbquant \- quantize a 24 bit color image
- X.SH SYNOPSIS
- X.nf
- Xfbquant [ -c<numcolors> ] [ -<type> ] [ -m<map> ] < rgb-image > mapped-image
- X.fi
- X.SH DESCRIPTION
- X.PP
- XConverts a 3 plane red-green-blue color image into a
- Xmapped color image. Uses Heckbert's adaptive partitioning
- Xcolor quantizing algorithm. It is strongly suggested that you make the
- Xnumber of colors used a power of 2, but not necessary for proper
- Xoperation of FBM.
- X.sp
- XIf you wish to requantize an image that is already mapped (for example,
- Xto reduce the number of colors), use "gray2clr -u" to unmap the image
- Xfirst. This unmapping step is also necessary to resize a color image
- Xusing fbext(1).
- X.sp
- XYou may specify a particular color map with the
- X.B -m
- Xoption. The argument is another mapped color image.
- X.sp
- XNote that even if you specify fewer than 256 colors, some output
- Xformats (SUN and FBM) will still use 8 bits to store each color index.
- XThe color map will be the specified length.
- X.SH OPTIONS
- X.TP
- X.BR -c<num>
- X.I number of colors
- Xto use for dithering. The range is 8 to 256, and the default is 256.
- X.TP
- X.BR -m<map>
- X.I colormap
- Xoption, specifies that the colormap from the
- X.I map
- Ximage is to be used to quantize he input. Colormaps may be efficiently
- Xstored by extracting very small rectangles
- Xfrom another color image:
- X.sp
- X % fbext 0 0 1 1 < image.clr > map.clr
- X.sp
- Xwhich stores a 1 pixel image with the desired map.
- X.TP
- X.BR -F
- X.I FBM,
- Xformat (by default, the default). You are guaranteed not
- Xto lose information by specifying FBM as the default.
- X.TP
- X.BR -G
- X.I GIF,
- XCompuserve GIF format.
- X.TP
- X.BR -I
- X.I IFF
- Xformat, interleaved bitmaps (ILBM), used by Amigas.
- XIt is recommended that you use 16 or 32 colors, because the EL Arts
- Xcode limits IFF files to 6 planes, and most Amiga software cannot
- Xhandle more than 32 colors anyway.
- X.TP
- X.BR -S
- X.I sun,
- XSun rasterfiles (not run length encoded).
- X.SH EXAMPLE
- X.PP
- XTo convert a 24 bit Sun rasterfile to an 8 bit mapped color rasterfile:
- X.sp
- X % fbquant -S < foo.24bit > foo.clr
- X.sp
- XTo convert a 24 bit Sun rasterfile to a 32 color Amiga image:
- X.sp
- X % fbext -a1.2 -w320 < foo.24bit | \
- X.br
- X fbquant -I -c32 > foo.iff
- X.sp
- XTo convert an FBM format RGB color image to a 16 color GIF image:
- X % fbext -a1.2 -w320 < foo.24bit | \
- X.br
- X fbquant -G -c16 > foo.gif
- X.SH SEE ALSO
- Xfbm(1) for general discussion, pbm(1) for PBM routines.
- X.SH BUGS
- XNone known.
- X.SH HISTORY
- XCopyright (c) 1989 by Michael L. Mauldin.
- XPermission is granted to use this program in whole or in part provided
- Xthat you do not sell it for profit and that this copyright notice is
- Xretained unchanged.
- X.TP
- X07-Mar-89 Michael L. Mauldin at Carnegie Mellon University
- XBeta release (version 0.9) mlm@cs.cmu.edu
- END_OF_FILE
- if test 2737 -ne `wc -c <'fbquant.1'`; then
- echo shar: \"'fbquant.1'\" unpacked with wrong size!
- fi
- # end of 'fbquant.1'
- fi
- if test -f 'fbrot.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'fbrot.c'\"
- else
- echo shar: Extracting \"'fbrot.c'\" \(2490 characters\)
- sed "s/^X//" >'fbrot.c' <<'END_OF_FILE'
- X/*****************************************************************
- X * fbrot.c: FBM Library 0.9 (Beta test) 07-Mar-89 Michael Mauldin
- X *
- X * Copyright (C) 1989 by Michael Mauldin. Permission is granted to
- X * use this file in whole or in part provided that you do not sell it
- X * for profit and that this copyright notice is retained unchanged.
- X *
- X * fbrot.c: Rotate image 90 degrees clockwise
- X *
- X * USAGE
- X * % fbrot < image1 > image2
- X *
- X * EDITLOG
- X * LastEditDate = Tue Mar 7 19:56:41 1989 - Michael Mauldin
- X * LastFileName = /usr2/mlm/src/misc/fbm/fbrot.c
- X *
- X * HISTORY
- X * 07-Mar-89 Michael Mauldin (mlm) at Carnegie Mellon University
- X * Beta release (version 0.9) mlm@cs.cmu.edu
- X *
- X * 22-Aug-88 Michael Mauldin (mlm) at Carnegie-Mellon University
- X * Created.
- X *****************************************************************/
- X
- X# include <stdio.h>
- X# include <math.h>
- X# include "fbm.h"
- X
- X# define USAGE \
- X "Usage: fbrot [ -<type> ] [ -90 | -180 | -270 ] < image > image"
- X
- X#ifndef lint
- Xstatic char *fbmid =
- X "$FBM fbrot.c <0.9> 07-Mar-89 (C) 1989 by Michael Mauldin$";
- X#endif
- X
- Xmain (argc, argv)
- Xchar *argv[];
- X{ FBM input, output;
- X int outtype = -1, rot = 90;
- X
- X /* Get the options */
- X while (--argc > 0 && (*++argv)[0] == '-')
- X { while (*++(*argv))
- X { switch (**argv)
- X {
- X case '9': rot=90; SKIPARG; break;
- X case '1': rot=180; SKIPARG; break;
- X case '2': rot=270; SKIPARG; break;
- X case 'A': outtype = FMT_ATK; break;
- X case 'B': outtype = FMT_FACE; break;
- X case 'F': outtype = FMT_FBM; break;
- X case 'G': outtype = FMT_GIF; break;
- X case 'I': outtype = FMT_IFF; break;
- X case 'L': outtype = FMT_LEAF; break;
- X case 'M': outtype = FMT_MCP; break;
- X case 'P': outtype = FMT_PBM; break;
- X case 'S': outtype = FMT_SUN; break;
- X case 'T': outtype = FMT_TIFF; break;
- X case 'X': outtype = FMT_X11; break;
- X case 'Z': outtype = FMT_PCX; break;
- X default: fprintf (stderr, "%s\n", USAGE);
- X exit (1);
- X }
- X }
- X }
- X
- X /* Clear the memory pointers so alloc_fbm won't be confused */
- X input.cm = input.bm = (unsigned char *) NULL;
- X output.cm = output.bm = (unsigned char *) NULL;
- X
- X /* Read the image and rotate it */
- X if (read_bitmap (&input, (char *) NULL))
- X { if (outtype < 0)
- X { if (input.hdr.planes == 1 && input.hdr.bits == 1)
- X { outtype = DEF_1BIT; }
- X else
- X { outtype = DEF_8BIT; }
- X }
- X
- X if (rotate_fbm (&input, &output, rot) &&
- X write_bitmap (&output, stdout, outtype))
- X { exit (0); }
- X }
- X
- X exit (1);
- X}
- END_OF_FILE
- if test 2490 -ne `wc -c <'fbrot.c'`; then
- echo shar: \"'fbrot.c'\" unpacked with wrong size!
- fi
- # end of 'fbrot.c'
- fi
- if test -f 'fbsample.1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'fbsample.1'\"
- else
- echo shar: Extracting \"'fbsample.1'\" \(2585 characters\)
- sed "s/^X//" >'fbsample.1' <<'END_OF_FILE'
- X.TH FBSAMPLE 1 07-Mar-89
- X.CM 3
- X.SH NAME
- Xfbsample \- convert 1bit image to grayscale by sampling
- X.SH SYNOPSIS
- X.nf
- Xfbsample [ -t'title' -c'credits' -g'grain' -n'nbr']
- X [ -<type> ] < bitmap > image
- X.fi
- X.SH DESCRIPTION
- X.PP
- XSamples a 1 bit deep pbm file using a square neighborhood of the
- Xspecified size, and outputs an 8 bit file. You will want to run
- X.I fbnorm
- Xon the output to expand the scale to 255, and there will be a small
- Xloss of sharpness, so
- X.I fbsharp
- Xwill also be useful. Once you have an 8 bit file, you can resize it
- Xarbitrarily, and then convert it back to a 1 bit file, if need be.
- XThe default neighborhood size is 8 by 8, which gives 65 different gray
- Xlevels.
- X.SH OPTIONS
- X.TP
- X.B -g
- X.I grain
- Xsize. The sample is taken every
- X.I grain
- Xpixels.
- X.TP
- X.B -n
- X.I neighborhood
- Xsize. The value will be the number of light pixels in the nearby NxN
- Xsquare. The values can range from 1 to 16.
- X.TP
- X.BR -t'title'
- X.I title,
- Xspecify a character string (up to 80 characters) to describe the image.
- XThe default is no title.
- X.TP
- X.BR -c'credits'
- X.I credits or subtitle,
- Xspecify a second character string (up to 80 characters) to describe the
- Ximage. The default is no credit string.
- X.TP
- X.BR -B
- X.I face
- Xformat, as used by Bennet Yee's
- X.I face
- Xprogram at CMU.
- X.TP
- X.BR -F
- X.I FBM,
- Xformat (by default, the default). You are guaranteed not
- Xto lose information by specifying FBM as the default.
- X.TP
- X.BR -G
- X.I GIF,
- XCompuserve GIF format.
- X.TP
- X.BR -I
- X.I IFF
- Xformat, interleaved bitmaps (ILBM), used by Amigas.
- X.TP
- X.BR -P
- X.I PBM,
- XJef Poskanzer's bitmap format.
- X.TP
- X.BR -S
- X.I sun,
- XSun rasterfiles (not run length encoded).
- X.PP
- X.SH EXAMPLE
- X.PP
- XSuppose you have a 480 by 600 face format file (-B) that you wish to
- Xshrink to 300 by 375 and convert to PostScript (say for inclusion
- Xin your door label). Here's a pipeline to do that:
- X.sp
- X.nf
- X % fbsample -n5 -g1 < my.face | \ # sample 5x5
- X fbnorm -b4 -w1 | # normalize
- X fbext -w300 | \ # make 300 pixels wide
- X fbhalf -s20 | \ # halftone and really sharpen
- X pbm2ps -s 1 > sdoor.ps # convert to postscript
- X.fi
- X.SH SEE ALSO
- Xfbnorm(1) to normalize the output,
- Xfbm(1) for general discussion, pbm(1) for PBM routines.
- X.SH BUGS
- XNone known.
- X.SH HISTORY
- XCopyright (c) 1989 by Michael L. Mauldin.
- XPermission is granted to use this program in whole or in part provided
- Xthat you do not sell it for profit and that this copyright notice is
- Xretained unchanged.
- X.TP
- X07-Mar-89 Michael L. Mauldin at Carnegie Mellon University
- XBeta release (version 0.9) mlm@cs.cmu.edu
- END_OF_FILE
- if test 2585 -ne `wc -c <'fbsample.1'`; then
- echo shar: \"'fbsample.1'\" unpacked with wrong size!
- fi
- # end of 'fbsample.1'
- fi
- if test -f 'fbsharp.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'fbsharp.c'\"
- else
- echo shar: Extracting \"'fbsharp.c'\" \(2905 characters\)
- sed "s/^X//" >'fbsharp.c' <<'END_OF_FILE'
- X/*****************************************************************
- X * fbsharp.c: FBM Library 0.9 (Beta test) 07-Mar-89 Michael Mauldin
- X *
- X * Copyright (C) 1989 by Michael Mauldin. Permission is granted to
- X * use this file in whole or in part provided that you do not sell it
- X * for profit and that this copyright notice is retained unchanged.
- X *
- X * fbsharp.c: Sharpen an image by using a Laplacian edge enhancement
- X *
- X * USAGE
- X * % fbsharp [ flags ] arguments
- X *
- X * EDITLOG
- X * LastEditDate = Tue Mar 7 19:56:44 1989 - Michael Mauldin
- X * LastFileName = /usr2/mlm/src/misc/fbm/fbsharp.c
- X *
- X * HISTORY
- X * 07-Mar-89 Michael Mauldin (mlm) at Carnegie Mellon University
- X * Beta release (version 0.9) mlm@cs.cmu.edu
- X *
- X * 10-Sep-88 Michael Mauldin (mlm) at Carnegie-Mellon University
- X * Created.
- X *****************************************************************/
- X
- X# include <stdio.h>
- X# include <math.h>
- X# include "fbm.h"
- X
- X# define USAGE "fbsharp [ -SF ] beta < 8bit > 8bit"
- X
- X#ifndef lint
- Xstatic char *fbmid =
- X "$FBM fbsharp.c <0.9> 07-Mar-89 (C) 1989 by Michael Mauldin$";
- X#endif
- X
- Xmain (argc, argv)
- Xchar *argv[];
- X{ int w, h, k;
- X double beta = 2.0;
- X FBM input, output;
- X int outtype = DEF_8BIT;
- X
- X /* Get the options */
- X while (--argc > 0 && (*++argv)[0] == '-')
- X { while (*++(*argv))
- X { switch (**argv)
- X {
- X case 'A': outtype = FMT_ATK; break;
- X case 'B': outtype = FMT_FACE; break;
- X case 'F': outtype = FMT_FBM; break;
- X case 'G': outtype = FMT_GIF; break;
- X case 'I': outtype = FMT_IFF; break;
- X case 'L': outtype = FMT_LEAF; break;
- X case 'M': outtype = FMT_MCP; break;
- X case 'P': outtype = FMT_PBM; break;
- X case 'S': outtype = FMT_SUN; break;
- X case 'T': outtype = FMT_TIFF; break;
- X case 'X': outtype = FMT_X11; break;
- X case 'Z': outtype = FMT_PCX; break;
- X default: fprintf (stderr, "%s\n", USAGE);
- X exit (1);
- X }
- X }
- X }
- X
- X /* Clear the memory pointers so alloc_fbm won't be confused */
- X input.cm = input.bm = (unsigned char *) NULL;
- X output.cm = output.bm = (unsigned char *) NULL;
- X
- X /* Read the image and sharpen it */
- X if (read_bitmap (&input, (char *) NULL))
- X {
- X if (input.hdr.bits != 8 || input.hdr.physbits != 8)
- X { fprintf (stderr,
- X "Can't handle images with %d bits and %d physbits per pixel\n",
- X input.hdr.bits, input.hdr.physbits);
- X exit (1);
- X }
- X
- X /* Argument is amount of sharpening */
- X if (argc > 0) { beta = atof (argv[0]); }
- X
- X /* Determine output height & width (oh*ow <= size) */
- X h = input.hdr.rows;
- X w = input.hdr.cols;
- X k = input.hdr.planes;
- X
- X fprintf (stderr,
- X "Sharpen \"%s\", beta %1.3lf [%dx%dx%d]\n",
- X input.hdr.title[0] ? input.hdr.title : "(untitled)",
- X beta, w, h, k);
- X
- X /* Sharpen the image using a digitial Laplacian */
- X if (sharpen_fbm (&input, &output, beta) &&
- X write_bitmap (&output, stdout, outtype))
- X { exit (0); }
- X }
- X
- X exit (1);
- X}
- END_OF_FILE
- if test 2905 -ne `wc -c <'fbsharp.c'`; then
- echo shar: \"'fbsharp.c'\" unpacked with wrong size!
- fi
- # end of 'fbsharp.c'
- fi
- if test -f 'flcavg.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'flcavg.c'\"
- else
- echo shar: Extracting \"'flcavg.c'\" \(3162 characters\)
- sed "s/^X//" >'flcavg.c' <<'END_OF_FILE'
- X/*****************************************************************
- X * flcavg.c: FBM Library 0.94 (Beta test) 20-May-89 Michael Mauldin
- X *
- X * Copyright (C) 1989 by Michael Mauldin. Permission is granted to
- X * use this file in whole or in part provided that you do not sell it
- X * for profit and that this copyright notice is retained unchanged.
- X *
- X * flcavg.c: Constrained average halftoning
- X *
- X * CONTENTS
- X * constravg_fbm (input, output, gamma)
- X *
- X * EDITLOG
- X * LastEditDate = Sat May 20 19:07:06 1989 - Michael Mauldin
- X * LastFileName = /usr2/mlm/src/misc/fbm/flcavg.c
- X *
- X * HISTORY
- X * 20-May-89 Michael Mauldin (mlm) at Carnegie Mellon University
- X * Bug fix from Dave Cohrs <dave@cs.wisc.edu>
- X *
- X * 07-Mar-89 Michael Mauldin (mlm) at Carnegie Mellon University
- X * Beta release (version 0.9) mlm@cs.cmu.edu
- X *
- X * 12-Nov-88 Michael Mauldin (mlm) at Carnegie-Mellon University
- X * Created.
- X *****************************************************************/
- X
- X# include <stdio.h>
- X# include <math.h>
- X# include <ctype.h>
- X# include "fbm.h"
- X
- X/****************************************************************
- X * constravg_fbm: Constrained Average halftoning
- X * Reference: Jarvis & Roberts, IEEE Trans. on Commun., v24n8, p 891-898
- X ****************************************************************/
- X
- X# define NBR 9
- X
- X#ifndef lint
- Xstatic char *fbmid =
- X "$FBM flcavg.c <0.94> 20-May-89 (C) 1989 by Michael Mauldin$";
- X#endif
- X
- Xconstravg_fbm (input, output, gamma)
- XFBM *input, *output;
- Xdouble gamma;
- X{ register unsigned char *bmp, *obm;
- X register int i, j, rowlen, w, h, sum, thresh, outrow;
- X int gamma100 = gamma * 100;
- X
- X if (input->hdr.planes != 1)
- X { fprintf (stderr, "constravg_fbm: can't halftone color images\n");
- X return (0);
- X }
- X
- X fprintf (stderr, "Constrained average halftoning, gamma %1.2lf\n", gamma);
- X
- X /* Allocate output */
- X output->hdr = input->hdr;
- X output->hdr.bits = 1;
- X output->hdr.physbits = 8;
- X outrow = 16 * ((input->hdr.cols + 15) / 16); /* Pad to even byte boundary */
- X output->hdr.rowlen = outrow;
- X output->hdr.plnlen = outrow*output->hdr.rows;
- X alloc_fbm (output);
- X
- X w = input->hdr.cols;
- X h = input->hdr.rows;
- X rowlen = input->hdr.rowlen;
- X
- X /* Use threshold of 1/2 in the output border */
- X for (j=0; j<h; j++)
- X { output->bm[j*outrow] = input->bm[j*rowlen] > (WHITE/2);
- X output->bm[j*outrow + (w-1)] = input->bm[j*rowlen + (w-1)] > (WHITE/2);
- X }
- X
- X for (i=0; i<w; i++)
- X { output->bm[i] = input->bm[i] > (WHITE/2);
- X output->bm[outrow*(h-1) + i] = input->bm[rowlen*(h-1) + i] > (WHITE/2);
- X }
- X
- X /*
- X * Now process the interior bits (use sum instead of average and divide
- X * by 9 when we are all done -- this allows fixed point arithmetic)
- X */
- X
- X for (j=1; j<h-1; j++)
- X { bmp = &input->bm[j*rowlen];
- X obm = &output->bm[j*outrow];
- X
- X for (i=1; i<w-1; i++)
- X { sum = bmp[(i-w) - 1] + bmp[(i-w)] + bmp[(i-w) + 1] +
- X bmp[i-1] + bmp[i] + bmp[i+1] +
- X bmp[i+w-1] + bmp[i+w] + bmp[i+w+1];
- X
- X thresh = gamma100/100 + (sum*WHITE - 2*gamma100*sum/100) / (NBR*WHITE);
- X obm[i] = (bmp[i] > thresh) ? 1 : 0;
- X }
- X }
- X
- X return (1);
- X}
- END_OF_FILE
- if test 3162 -ne `wc -c <'flcavg.c'`; then
- echo shar: \"'flcavg.c'\" unpacked with wrong size!
- fi
- # end of 'flcavg.c'
- fi
- if test -f 'flthre.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'flthre.c'\"
- else
- echo shar: Extracting \"'flthre.c'\" \(2328 characters\)
- sed "s/^X//" >'flthre.c' <<'END_OF_FILE'
- X1/*****************************************************************
- X * flthre.c: FBM Library 0.94 (Beta test) 20-May-89 Michael Mauldin
- X *
- X * Copyright (C) 1989 by Michael Mauldin. Permission is granted to
- X * use this file in whole or in part provided that you do not sell it
- X * for profit and that this copyright notice is retained unchanged.
- X *
- X * flthre.c:
- X *
- X * CONTENTS:
- X * thesh_fbm (input, output, thresh)
- X *
- X * EDITLOG
- X * LastEditDate = Sat May 20 19:06:37 1989 - Michael Mauldin
- X * LastFileName = /usr2/mlm/src/misc/fbm/flthre.c
- X *
- X * HISTORY
- X * 20-May-89 Michael Mauldin (mlm) at Carnegie Mellon University
- X * Bug fix from Dave Cohrs <dave@cs.wisc.edu>
- X *
- X * 07-Mar-89 Michael Mauldin (mlm) at Carnegie Mellon University
- X * Beta release (version 0.9) mlm@cs.cmu.edu
- X *
- X * 10-Dec-88 Michael Mauldin (mlm) at Carnegie-Mellon University
- X * Created.
- X *****************************************************************/
- X
- X
- X# include <stdio.h>
- X# include <math.h>
- X# include <ctype.h>
- X# include "fbm.h"
- X
- X/*****************************************************************
- X * thesh_fbm: Threshhold halftoning
- X *****************************************************************/
- X
- X# define RAND(RN) (((seed = 1103515245 * seed + 12345) >> 12) % (RN))
- X
- X#ifndef lint
- Xstatic char *fbmid =
- X "$FBM flthre.c <0.94> 20-May-89 (C) 1989 by Michael Mauldin$";
- X#endif
- X
- Xthesh_fbm (input, output, thresh)
- XFBM *input, *output;
- Xregister int thresh;
- X{ register unsigned char *bmp, *obm;
- X register int i, j, rowlen, w, h, outrow;
- X
- X if (input->hdr.planes != 1)
- X { fprintf (stderr, "thesh_fbm: can't halftone color images\n");
- X return (0);
- X }
- X
- X fprintf (stderr, "Threshhold halftoning, thesh %d\n", thresh);
- X
- X /* Allocate output */
- X free_fbm (output);
- X output->hdr = input->hdr;
- X output->hdr.bits = 1;
- X output->hdr.physbits = 8;
- X outrow = 16 * ((input->hdr.cols + 15) / 16); /* Pad to even byte boundary */
- X output->hdr.rowlen = outrow;
- X output->hdr.plnlen = outrow*output->hdr.rows;
- X alloc_fbm (output);
- X
- X w = input->hdr.cols;
- X h = input->hdr.rows;
- X rowlen = input->hdr.rowlen;
- X
- X /* Now do threshholding */
- X for (j=0; j<h; j++)
- X { /* scan left to right */
- X bmp = &input->bm[j*rowlen];
- X obm = &output->bm[j*outrow];
- X
- X for (i=1; i<w; i++)
- X { obm[i] = bmp[i] > thresh ? WHITE : BLACK; }
- X }
- X
- X return (1);
- X}
- END_OF_FILE
- if test 2328 -ne `wc -c <'flthre.c'`; then
- echo shar: \"'flthre.c'\" unpacked with wrong size!
- fi
- # end of 'flthre.c'
- fi
- if test -f 'flwrfb.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'flwrfb.c'\"
- else
- echo shar: Extracting \"'flwrfb.c'\" \(2921 characters\)
- sed "s/^X//" >'flwrfb.c' <<'END_OF_FILE'
- X/*****************************************************************
- X * flwrfb.c: FBM Library 0.9 (Beta test) 07-Mar-89 Michael Mauldin
- X *
- X * Copyright (C) 1989 by Michael Mauldin. Permission is granted to
- X * use this file in whole or in part provided that you do not sell it
- X * for profit and that this copyright notice is retained unchanged.
- X *
- X * flwrfb.c:
- X *
- X * CONTENTS
- X * write_fbm (image, wfile)
- X * write_hdr_fbm (image, wfile)
- X *
- X * EDITLOG
- X * LastEditDate = Tue Mar 7 19:57:39 1989 - Michael Mauldin
- X * LastFileName = /usr2/mlm/src/misc/fbm/flwrfb.c
- X *
- X * HISTORY
- X * 07-Mar-89 Michael Mauldin (mlm) at Carnegie Mellon University
- X * Beta release (version 0.9) mlm@cs.cmu.edu
- X *
- X * 12-Nov-88 Michael Mauldin (mlm) at Carnegie-Mellon University
- X * Created.
- X *****************************************************************/
- X
- X# include <stdio.h>
- X# include <math.h>
- X# include <ctype.h>
- X# include "fbm.h"
- X
- X/****************************************************************
- X * write_fbm: Write an image to a stream
- X ****************************************************************/
- X
- X#ifndef lint
- Xstatic char *fbmid =
- X "$FBM flwrfb.c <0.9> 07-Mar-89 (C) 1989 by Michael Mauldin$";
- X#endif
- X
- Xwrite_fbm (image, wfile)
- Xregister FBM *image;
- Xregister FILE *wfile;
- X{ register int k, j, rowlen, plnlen;
- X register unsigned char *bmptr;
- X
- X if (! write_hdr_fbm (image, wfile)) return (0);
- X
- X rowlen = image->hdr.rowlen;
- X plnlen = image->hdr.plnlen;
- X
- X if (image->hdr.clrlen > 0)
- X { if (!fwrite (image->cm, image->hdr.clrlen, 1, wfile))
- X { perror ("write_fbm (colormap)"); return (0); }
- X }
- X
- X for (k=0; k<image->hdr.planes; k++)
- X { bmptr = &(image->bm[k*plnlen]);
- X
- X for (j=0; j<image->hdr.rows; j++, bmptr += rowlen)
- X { if (! fwrite (bmptr, 1, rowlen, wfile))
- X { perror ("write_fbm"); return (0); }
- X }
- X }
- X
- X return (1);
- X}
- X
- X/****************************************************************
- X * write_hdr_fbm: Write an image header to a stream
- X ****************************************************************/
- X
- Xwrite_hdr_fbm (image, wfile)
- Xregister FBM *image;
- Xregister FILE *wfile;
- X{ FBMFILEHDR file_hdr;
- X
- X strncpy (file_hdr.magic, FBM_MAGIC, 8);
- X sprintf (file_hdr.cols, "%7d", image->hdr.cols);
- X sprintf (file_hdr.rows, "%7d", image->hdr.rows);
- X sprintf (file_hdr.planes, "%7d", image->hdr.planes);
- X sprintf (file_hdr.bits, "%7d", image->hdr.bits);
- X sprintf (file_hdr.physbits, "%7d", image->hdr.physbits);
- X sprintf (file_hdr.rowlen, "%11d", image->hdr.rowlen);
- X sprintf (file_hdr.plnlen, "%11d", image->hdr.plnlen);
- X sprintf (file_hdr.clrlen, "%11d", image->hdr.clrlen);
- X sprintf (file_hdr.aspect, "%11.6lf", image->hdr.aspect);
- X strncpy (file_hdr.title, image->hdr.title, FBM_MAX_TITLE);
- X strncpy (file_hdr.credits, image->hdr.credits, FBM_MAX_TITLE);
- X
- X if (! fwrite (&file_hdr, sizeof (file_hdr), 1, wfile))
- X { perror ("write_fbm (header)"); return (0); }
- X
- X return (1);
- X}
- END_OF_FILE
- if test 2921 -ne `wc -c <'flwrfb.c'`; then
- echo shar: \"'flwrfb.c'\" unpacked with wrong size!
- fi
- # end of 'flwrfb.c'
- fi
- if test -f 'gray2clr.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'gray2clr.c'\"
- else
- echo shar: Extracting \"'gray2clr.c'\" \(2410 characters\)
- sed "s/^X//" >'gray2clr.c' <<'END_OF_FILE'
- X/*****************************************************************
- X * gray2clr.c: FBM Library 0.9 (Beta test) 07-Mar-89 Michael Mauldin
- X *
- X * Copyright (C) 1989 by Michael Mauldin. Permission is granted to
- X * use this file in whole or in part provided that you do not sell it
- X * for profit and that this copyright notice is retained unchanged.
- X *
- X * gray2clr.c:
- X *
- X * USAGE
- X * % gray2clr [ flags ] arguments
- X *
- X * EDITLOG
- X * LastEditDate = Thu Apr 20 17:05:31 1989 - Michael Mauldin
- X * LastFileName = /usr2/mlm/src/misc/fbm/gray2clr.c
- X *
- X * HISTORY
- X * 07-Mar-89 Michael Mauldin (mlm) at Carnegie Mellon University
- X * Beta release (version 0.9) mlm@cs.cmu.edu
- X *
- X * 1-Dec-88 Michael Mauldin (mlm) at Carnegie-Mellon University
- X * Created.
- X *****************************************************************/
- X
- X# include <stdio.h>
- X# include <math.h>
- X# include "fbm.h"
- X
- X# define USAGE "gray2clr [ -<type> ] [ -u ] < gray > color"
- X
- X#ifndef lint
- Xstatic char *fbmid =
- X "$FBM gray2clr.c <0.9> 07-Mar-89 (C) 1989 by Michael Mauldin$";
- X#endif
- X
- Xmain (argc, argv)
- Xchar *argv[];
- X{ FBM input, output;
- X int outtype = DEF_8BIT;
- X int mapped = 1;
- X
- X /* If invoked as 'unmap', set option to mapped=0 */
- X if (strcmp (argv[0] + strlen (argv[0]) - 5, "unmap") == 0)
- X { mapped = 0; }
- X
- X /* Get the options */
- X while (--argc > 0 && (*++argv)[0] == '-')
- X { while (*++(*argv))
- X { switch (**argv)
- X { case 'u': mapped = 0; break;
- X case 'A': outtype = FMT_ATK; break;
- X case 'B': outtype = FMT_FACE; break;
- X case 'F': outtype = FMT_FBM; break;
- X case 'G': outtype = FMT_GIF; break;
- X case 'I': outtype = FMT_IFF; break;
- X case 'L': outtype = FMT_LEAF; break;
- X case 'M': outtype = FMT_MCP; break;
- X case 'P': outtype = FMT_PBM; break;
- X case 'S': outtype = FMT_SUN; break;
- X case 'T': outtype = FMT_TIFF; break;
- X case 'X': outtype = FMT_X11; break;
- X case 'Z': outtype = FMT_PCX; break;
- X default: fprintf (stderr, "%s\n", USAGE);
- X exit (1);
- X }
- X }
- X }
- X
- X /* Clear the memory pointers so alloc_fbm won't be confused */
- X input.cm = input.bm = (unsigned char *) NULL;
- X output.cm = output.bm = (unsigned char *) NULL;
- X
- X /* Read the image and convert it */
- X if (read_bitmap (&input, (char *) NULL) &&
- X (mapped ?
- X gray2clr (&input, &output, outtype == FMT_SUN) :
- X clr_unmap (&input, &output)) &&
- X write_bitmap (&output, stdout, outtype))
- X { exit (0); }
- X
- X exit (1);
- X}
- END_OF_FILE
- if test 2410 -ne `wc -c <'gray2clr.c'`; then
- echo shar: \"'gray2clr.c'\" unpacked with wrong size!
- fi
- # end of 'gray2clr.c'
- fi
- if test -f 'qrt2fbm.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'qrt2fbm.c'\"
- else
- echo shar: Extracting \"'qrt2fbm.c'\" \(2571 characters\)
- sed "s/^X//" >'qrt2fbm.c' <<'END_OF_FILE'
- X/*****************************************************************
- X * qrt2fbm.c: FBM Library 0.91 (Beta Test) 7-Apr-89 Michael Mauldin
- X *
- X * Copyright (C) 1989 by Michael Mauldin. Permission is granted to
- X * use this file in whole or in part provided that you do not sell it
- X * for profit and that this copyright notice is retained unchanged.
- X *
- X * qrt2fbm.c: Convert QRT format (from the QRT ray tracer)
- X *
- X * USAGE
- X * % qrt2fbm -t'title' -c'credits' < qrtfile > fbm
- X *
- X * EDITLOG
- X * LastEditDate = Wed May 3 23:35:24 1989 - Michael Mauldin
- X * LastFileName = /usr2/mlm/src/misc/fbm/qrt2fbm.c
- X *
- X * HISTORY
- X * 7-Apr-89 Michael Mauldin (mlm) at Carnegie-Mellon University
- X * Installed, code by Butler Hines.
- X *
- X *****************************************************************/
- X
- X# include <stdio.h>
- X# include "fbm.h"
- X
- X# define USAGE \
- X"Usage: qrt2fbm [ -t'title' -c'credits' ] < qrtfile > fbm"
- X
- X#ifndef lint
- Xstatic char *fbmid =
- X "$FBM qrt2fbm.c <0.91> 07-Apr-89 (C) 1989 by Michael Mauldin$";
- X#endif
- X
- Xmain (argc, argv)
- Xchar *argv[];
- X{ register int j, k, rowlen;
- X double aspect = 0.56;
- X int rows, cols, line, len, planes=3;
- X FBMHDR hdr;
- X unsigned char *buf;
- X char title[FBM_MAX_TITLE], credits[FBM_MAX_TITLE];
- X
- X /* Get the options */
- X while (--argc > 0 && (*++argv)[0] == '-')
- X { while (*++(*argv))
- X { switch (**argv)
- X {
- X case 't': strncpy (title, *argv+1, FBM_MAX_TITLE);
- X title[FBM_MAX_TITLE-1] = '\0';
- X CLRARG; break;
- X case 'c': strncpy (credits, *argv+1, FBM_MAX_TITLE);
- X credits[FBM_MAX_TITLE-1] = '\0';
- X CLRARG; break;
- X default: fprintf (stderr, "%s\n", USAGE);
- X exit (1);
- X }
- X }
- X }
- X
- X cols = getchar();
- X cols |= (getchar()<<8);
- X rows = getchar();
- X rows |= (getchar()<<8);
- X
- X rowlen = 2 * ((cols * 8 + 15) / 16);
- X
- X /* Build header */
- X hdr.rows = rows;
- X hdr.cols = cols;
- X hdr.planes = planes;
- X hdr.bits = 8;
- X hdr.physbits = 8;
- X hdr.rowlen = rowlen;
- X hdr.plnlen = hdr.rowlen * rows;
- X hdr.clrlen = 0;
- X hdr.aspect = aspect;
- X strcpy (hdr.title, title);
- X strcpy (hdr.credits, credits);
- X
- X write_hdr_fbm (&hdr, stdout);
- X
- X len = planes*cols;
- X buf = (unsigned char *) malloc (rows*len);
- X
- X for (j=0; j<rows; j++){
- X line = getchar();
- X line |= (getchar()<<8);
- X if (! fread (&buf[j*len], len, 1, stdin))
- X { fprintf (stderr, "premature end of file on input at line %d\n", line);
- X break;
- X }
- X }
- X
- X for(k=0; k<planes; k++){
- X for (j=0; j<rows; j++){
- X if (! fwrite (&buf[j*len+k*cols], rowlen, 1, stdout))
- X { perror ("qrt2fbm"); exit (1); }
- X }
- X }
- X
- X exit (0);
- X}
- END_OF_FILE
- if test 2571 -ne `wc -c <'qrt2fbm.c'`; then
- echo shar: \"'qrt2fbm.c'\" unpacked with wrong size!
- fi
- # end of 'qrt2fbm.c'
- fi
- echo shar: End of archive 2 \(of 8\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 8 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-